Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support multiple named bibtex files #12

Open
wants to merge 35 commits into
base: master
Choose a base branch
from

Conversation

pholthaus
Copy link

I don't know if pull requests are desired or not. My modifications accomplish the following:

Define multiple bib files like this in pelicanconf.py:

PUBLICATIONS = { 'Conference Proceedings': 'content/proceedings.bib',
                 'Journal Articles': 'content/articles.bib'}

A header will be generated by default, but can be disabled by setting the following:

PUBLICATIONS_HEADER = False

Also, publications now are sorted by year so that templates can insert headers in between.
For a live example, please see https://robothouse.herts.ac.uk/publications/

@vene
Copy link
Owner

vene commented Aug 16, 2018

This is a great idea!

I've also seen people group papers by research topic etc. On my website (where i just manually maintain a Markdown list) I now moved to "selected papers" followed by a long list.

Of course for the selected papers I don't want year sub-headers. So i wonder how we can make this more flexible and customizable (maybe with a sort of dict of options in the config file?)
At the same time it can be bad to aim for overly general features from the start

@pholthaus
Copy link
Author

pholthaus commented Aug 16, 2018

Yeah, you are right. I have added some variables that should do the job.

edit: removed template

@pholthaus
Copy link
Author

Ah, I see what I missed, we need the settings per file.

@pholthaus
Copy link
Author

In the current state, it allows for such a configuration:

PUBLICATIONS_NAVBAR = True
PUBLICATIONS = {
  'peer': {
    'title': 'Peer Reviewed',
    'file': 'content/peer.bib',
    'split_link': False,
    'highlight': ['Patrick Holthaus'] },
  'others': {
    'title': 'Others',
    'file': 'content/others.bib',
    'split': False,
    'bottom_link': False,
    'highlight': ['Patrick Holthaus'] }
}

@pholthaus
Copy link
Author

Updated template:

{% extends "page.html" %}

{% block content %}

<!-- bibtex popup -->
<script bib="text/javascript">
function disp(s) {
    var win;
    var doc;
    win = window.open("", "rh-bibtex-entry",'width=600,height=200');
    doc = win.document;
    doc.open("text/html");
    doc.write("<pre>" + s + "</pre>");
    doc.close();
}
</script>

<!-- header part: original bootstrap pages content block -->
<section id="content" class="body">
    {% if page.title %}
        <h1 class="entry-title">{{ page.title }}</h1>
    {% endif %}
    {% import 'includes/translations.html' as translations with context %}
    {{ translations.translations_for(page) }}
    {% if PDF_PROCESSOR %}
        <a href="{{ SITEURL }}/pdf/{{ page.slug }}.pdf">
            get the pdf
        </a>
    {% endif %}
    <div class="entry-content">
        {{ page.content }}

<!-- add header navbar -->
{% if PUBLICATIONS_NAVBAR %}
    <p>
    {% for bib in publications %}
        <a class="reference external" href="#{{ bib }}">{{ publications[bib]['title'] }}</a>
        {% if not loop.last %}&middot;{% endif %}
    {% endfor %}
    </p>
{% endif %}

<!-- add publication list -->
{% for bib in publications %}
    <div class="publications" id="{{ bib }}">
        {% if publications[bib]['header'] %}
          <h2>{{ publications[bib]['title'] }}</h2>
        {% endif %}
        {% if publications[bib]['split'] %}
            {% set remember = namespace(year="0") %}
            {% for key, year, text, bibtex, pdf, slides, poster in publications[bib]['data'] %}
                {% if remember.year != year %}
                    {% if remember.year !="0" %}
                        </ul>
                        {% if publications[bib]['split_link'] %}
                        <div style="text-align:right"><i class="fa fa-arrow-up"></i> <a href="#">Back to top</a></div>
                        {% endif %}
                    {% endif %}
                    <h3>{{ year }}</h3>
                    <ul>
                    {% set remember.year=year %}
                {% endif %}
                <li style="margin: 5px 0;" id="{{ key }}">{{ text }} [&nbsp;<a href="javascript:disp('{{ bibtex|replace('\n', '\\n')|escape|forceescape }}');">BibTeX</a>&nbsp;]
                {% for label, target in [('PDF', pdf), ('Slides', slides), ('Poster', poster)] %}
                    {{ "[&nbsp;<a href=\"%s\">%s</a>&nbsp;]" % (target, label) if target }}
                {% endfor %}
                </li>
            {% endfor %}
            </ul>
        {% else %}
            <ul>
            {% for key, year, text, bibtex, pdf, slides, poster in publications[bib]['data'] %}
                <li style="margin: 5px 0;" id="{{ key }}">{{ text }} [&nbsp;<a href="javascript:disp('{{ bibtex|replace('\n', '\\n')|escape|forceescape }}');">BibTeX</a>&nbsp;]
                {% for label, target in [('PDF', pdf), ('Slides', slides), ('Poster', poster)] %}
                    {{ "[&nbsp;<a href=\"%s\">%s</a>&nbsp;]" % (target, label) if target }}
                {% endfor %}
                </li>
            {% endfor %}
            </ul>
        {% endif %}

        {{ publications[bib]['link'] }}
          {% if not loop.last and publications[bib]['bottom_link'] %}
              <div style="text-align:right"><i class="fa fa-arrow-up"></i> <a href="#">Back to top</a></div>
          {% endif %}
    </div>
{% endfor %}

<!-- footer part: original bootstrap pages content block -->
        {% if page.comments == 'enabled' %}
            {% include 'includes/comments.html' %}
        {% endif %}
    </div>
</section>

{% endblock %}

@pholthaus
Copy link
Author

I have updated my personal website now. This is actually a live example of the plugin, the template and configuration above:

https://patrick.holthaus.info/publications/

@pholthaus
Copy link
Author

the source code for this site can now be found at https://gitlab.com/pholthau/personal-website

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants